import 'package:flutter/material.dart';

import 'package:flutter_swiper/flutter_swiper.dart';

class SwiperDemo extends StatefulWidget {
  SwiperDemo({Key key}) : super(key: key);

  @override
  _SwiperDemoState createState() => _SwiperDemoState();
}

class _SwiperDemoState extends State<SwiperDemo> {

  List<Map> imageList = [
    {
      'url': 'https://www.itying.com/images/flutter/1.png',
    },
    {
      'url': 'https://www.itying.com/images/flutter/2.png',
    },
    {
      'url': 'https://www.itying.com/images/flutter/3.png',
    },
    {
      'url': 'https://www.itying.com/images/flutter/4.png',
    }
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('轮播图演示')
      ), 
      body: Column(
        children: <Widget>[
          Container(
            width: double.infinity,
            child: AspectRatio(
              aspectRatio: 16/9,
              child: new Swiper(
                itemBuilder: (BuildContext context, int index) {
                  return new Image.network(
                    imageList[index]['url'],
                    fit: BoxFit.fill,
                  );
                },
                itemCount: imageList.length,
                pagination: new SwiperPagination(),
                control: new SwiperControl(),
                loop: true,
                autoplay: true,
              )
            )
          ),
          Row(
            children: <Widget>[
              Text('我是一文本')
            ],
          )
        ], 
      )
    );
  }
}